import axios from "axios";
import 'dotenv/config';

const {
  FEISHU_API_URL: feishuApi,
  FEISHU_APP_ID: app_id,
  FEISHU_APP_SECRET: app_secret,
} = process.env;

export async function getTenantAccessToken() {
  const {
    data: { msg, tenant_access_token, expire },
  } = await axios.post(`${feishuApi}/auth/v3/tenant_access_token/internal`, {
    app_id,
    app_secret
  });


  if (msg != "ok") throw Error(msg);
  return tenant_access_token;
}
